﻿<navigation:Page x:Class="Wintellect.Touch.Views.ElementResizingPage" 
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 mc:Ignorable="d"
                 xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
                 xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
                 xmlns:Touch="clr-namespace:Wintellect.Touch;assembly=Wintellect.Touch" 
                 d:DesignWidth="960" d:DesignHeight="480"
                 Title="ImageResizingPage Page">
    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid Grid.Column="0" Grid.RowSpan="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="30"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <TextBlock Grid.Row="0" Grid.Column="0" Text="Clip To Parent: "/>
            <CheckBox Grid.Row="0" Grid.Column="1" x:Name="ClipToParentCheckBox" Checked="HandleClipToParentCheckChanged" Unchecked="HandleClipToParentCheckChanged" IsChecked="True"/>
            <TextBlock Grid.Row="1" Grid.Column="0" Text="Limit Min Size to Actual: "/>
            <CheckBox Grid.Row="1" Grid.Column="1" x:Name="LimitMinimumScaleCheckBox" Checked="HandleLimitMinimumScaleCheckChanged" Unchecked="HandleLimitMinimumScaleCheckChanged" IsChecked="True"/>
            <TextBlock Grid.Row="2" Grid.Column="0" Text="Limit X/Y Move to Parent: "/>
            <CheckBox Grid.Row="2" Grid.Column="1" x:Name="LimitTranslationCheckBox" Checked="HandleLimitTranslationCheckChanged" Unchecked="HandleLimitTranslationCheckChanged" IsChecked="True"/>
            <Button Grid.Row="3" Grid.ColumnSpan="2" Content="Reset Elements" Click="HandleResetElementClick"/>

            <TextBlock Grid.Row="4" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Bottom" Text="Image-Specific" FontWeight="Bold"/>
            <TextBlock Grid.Row="5" Grid.Column="0" Text="Reset On Image Change:"/>
            <CheckBox Grid.Row="5" Grid.Column="1" x:Name="ResetOnImageChange" Checked="HandleResetOnImageChangeCheckChanged" Unchecked="HandleResetOnImageChangeCheckChanged" IsChecked="True"/>
            <Button Grid.Row="6" Grid.ColumnSpan="2" Content="Next Image" Click="HandleNextImageButtonClick"/>

            <TextBlock Grid.Row="99" Grid.ColumnSpan="2" VerticalAlignment="Bottom" Width="175" TextWrapping="Wrap" FontStyle="Italic"
                       Text="Note: Using the sliders to zoom out does NOT trigger translation correction."/>
        </Grid>

        <Grid Grid.Column="1" Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Border Grid.Column="0" Grid.Row="0" BorderBrush="Black" BorderThickness="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <Grid>
                    <Ellipse x:Name="ResizeShape" Fill="Purple">
                        <i:Interaction.Behaviors>
                            <Touch:ElementResizingBehavior x:Name="ResizeShapeBehavior"/>
                        </i:Interaction.Behaviors>
                    </Ellipse>
                </Grid>
            </Border>
            <StackPanel Grid.Row="1" Grid.Column="0">
                <Slider x:Name="ShapeXZoomSlider" Value="{Binding ElementName=ResizeShape, Path=RenderTransform.ScaleX, Mode=TwoWay}"/>
                <TextBlock HorizontalAlignment="Center" Text="{Binding ElementName=ShapeXZoomSlider, Path=Value, StringFormat=\{0:F2\}}"/>
            </StackPanel>
            <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
                <Slider x:Name="ShapeYZoomSlider" Value="{Binding ElementName=ResizeShape, Path=RenderTransform.ScaleY, Mode=TwoWay}" Orientation="Vertical" IsDirectionReversed="True"/>
                <TextBlock VerticalAlignment="Center" Text="{Binding ElementName=ShapeYZoomSlider, Path=Value, StringFormat=\{0:F2\}}"/>
            </StackPanel>
        </Grid>

        <Grid Grid.Column="2" Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Border Grid.Column="0" Grid.Row="0" BorderBrush="Black" BorderThickness="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <Grid>
                    <Image x:Name="ResizeImage" Source="/Wintellect.Touch.Sample;component/SampleData/SampleDataSource/SampleDataSource_Files/image01.png">
                        <i:Interaction.Behaviors>
                            <Touch:ImageElementResizingBehavior x:Name="ResizeImageBehavior"/>
                        </i:Interaction.Behaviors>
                    </Image>
                </Grid>
            </Border>
            <StackPanel Grid.Row="1" Grid.Column="0">
                <Slider x:Name="ImageXZoomSlider" Value="{Binding ElementName=ResizeImage, Path=RenderTransform.ScaleX, Mode=TwoWay}"/>
                <TextBlock HorizontalAlignment="Center" Text="{Binding ElementName=ImageXZoomSlider, Path=Value, StringFormat=\{0:F2\}}"/>
            </StackPanel>
            <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
                <Slider x:Name="ImageYZoomSlider" Value="{Binding ElementName=ResizeImage, Path=RenderTransform.ScaleY, Mode=TwoWay}" Orientation="Vertical" IsDirectionReversed="True"/>
                <TextBlock VerticalAlignment="Center" Text="{Binding ElementName=ImageYZoomSlider, Path=Value, StringFormat=\{0:F2\}}"/>
            </StackPanel>
        </Grid>
        
    </Grid>
</navigation:Page>
